package greetings

import "fmt"

/**
用切片模拟一个栈
*/

func stackAppend(s []int, v int) {
	s = append(s, v)
}

func stackPeek(s []int) int {
	return s[len(s)-1]
}

func stackPop(s []int) {
	s = s[:len(s)-1]
}

func stackRemove(slice []int, i int) []int {
	copy(slice[i:], slice[i+1:])
	return slice[:len(slice)-1]
}

func main() {
	s := []int{5, 6, 7, 8, 9}
	fmt.Println(stackRemove(s, 2)) // "[5 6 8 9]"
}
